A walkthrough of Ernest (2005)’s original analytical approach, from close reading of the paper.
Ernest drew data from the Andrews LTER, the Sevilleta, Niwot Ridge, and Portal. For details of these field sites, see the relevant publications cited in Ernest (2005).
replicate-becsThe same datasets are available online, from these sources.
download_raw_paper_data()
Process raw data into the appropriate format. This is a data table with a record for each individual and columns for species and weight in grams. By default these tables will be stored in subdirectores of replicate-becs/data/paper/processed
process_raw_data()
Loading in data version 1.107.0
[1] TRUE
=======
rr process_raw_data(storagepath = storagepath)
Loading in data version 1.106.0
[1] TRUE
>>>>>>> energy-assumptions
Load data tables for each community.
communities <- load_paper_data()
Each community should be a data table with columns for species and size for each individual, for example:
rr names(communities)[[1]]
[1] \andrews\
rr head(communities[[1]])
Although the same datasets are now available online, they may have changed somewhat since 2005 (due to error checking, etc). Ernest (2005) may also have taken some cleaning and filtering steps, the details of which could have been omitted from the manuscript due to length restrictions. For example, many studies using data from the Portal Project omit ground squirrels, because although they may be within the “small mammal” size range, they are not target taxa for the sampling method.
Ernest (2005) reported summary statistics of her datasets; here I compare them to the corresponding dataset in the 2019 data.
<<<<<<< HEADsummary_stats_comparison = compare_summary_stats()
=======
rr summary_stats_comparison = compare_summary_stats(storagepath = storagepath)
>>>>>>> energy-assumptions
Column `community_name` joining character vector and factor, coercing into character vector
rr print(summary_stats_comparison)
Ernest 2005 Fig 1
replicate-becsFor every individual, calculate metabolic rate and assign to a size class.
rr communities_energy <- lapply(communities, FUN = make_community_table, ln_units = 0.2) head(communities_energy[[1]])
For each community, sum total energy use for each size class, and convert to the proportion of total energy use for that community.
rr bseds <- lapply(communities_energy, FUN = make_bsed) head(bseds[[1]])
replicate-becsCalculate mean mass of each species in each community.
<<<<<<< HEADbsds <- lapply(communities, FUN = make_bsd)
head(bsds[[1]])
=======
rr bsds <- lapply(communities, FUN = make_bsd) head(bsds[[1]])
>>>>>>> energy-assumptions
replicate-becsenergetic_dom <- lapply(communities_energy, FUN = energetic_dominance)
head(energetic_dom[[1]])
=======
rr energetic_dom <- lapply(communities_energy, FUN = energetic_dominance) head(energetic_dom[[1]])
>>>>>>> energy-assumptions
replicate-becsbsed_unif_sizeabund_bootstraps <- lapply(communities, FUN = community_bootstrap, bootstrap_function = 'bootstrap_unif_sizeabund_bsed_doi', nbootstraps = 10000)
See issue #4 on github.
<<<<<<< HEADreplicate-becscommunity_combination_indices = utils::combn(x = c(1:9), m = 2, simplify = TRUE) %>%
t() %>%
as.data.frame() %>%
dplyr::rename(community_a = V1, community_b = V2)
combine_communities = function(indices, communities) {
community_combination = list(community_a = communities[[indices[1]]], community_b = communities[[indices[2]]], community_names = c(names(communities)[[indices[1]]], names(communities)[[indices[2]]]))
return(community_combination)
}
community_combinations = apply(community_combination_indices, MARGIN = 1, FUN = combine_communities, communities = communities)
=======
rr community_combination_indices = utils::combn(x = c(1:9), m = 2, simplify = TRUE) %>% t() %>% as.data.frame() %>% dplyr::rename(community_a = V1, community_b = V2)
combine_communities = function(indices, communities) { community_combination = list(community_a = communities[[indices[1]]], community_b = communities[[indices[2]]], community_names = c(names(communities)[[indices[1]]], names(communities)[[indices[2]]]))
return(community_combination) }
community_combinations = apply(community_combination_indices, MARGIN = 1, FUN = combine_communities, communities = communities)
>>>>>>> energy-assumptions
bsed_crosscomm_bootstraps = lapply(community_combinations, FUN = community_bootstrap,
bootstrap_function = 'bootstrap_crosscomm_bseds', nbootstraps = 10000)
<<<<<<< HEAD
See histogram of p values for comparisons to see if commuities’ BSEDs are the same or different.
ernest_key = read.csv(file.path(storagepath, 'ernest_key.csv'), stringsAsFactors = F)
ernest_bsds_uniform_results = read.csv(file.path(storagepath, 'ernest_appendixA.csv'), stringsAsFactors = F) %>%
dplyr::left_join(ernest_key, by = 'site')
print(ernest_bsds_uniform_results)
=======
rr ernest_key = read.csv(file.path(storagepath, ‘ernest-2005-files’, ‘ernest_key.csv’), stringsAsFactors = F) ernest_bsds_uniform_results = read.csv(file.path(storagepath, ‘ernest-2005-files’, ‘ernest_appendixA.csv’), stringsAsFactors = F) %>% dplyr::left_join(ernest_key, by = ‘site’) print(ernest_bsds_uniform_results)
>>>>>>> energy-assumptions
replicate-becs:From Zar (1999) Biostatistical Analysis.
Tables of critical values were entered by hand from the appendix to Zar (1999).
The \(\delta\) corrected KS test does not correspond to the results from Ernest when the species mean body size values are on an untransformed scale.
Using the natural log of the species mean body size value, however…:
With mean mass logged, all the results replicate qualitatively (i.e. not significantly different from uniform) and Niwot, for which the currently-available data most closely matches that reported in Ernest (2005), replicates almost exactly numerically.
Ernest (2005) used a two-sample Kolmogorov-Smirnov test to compare every possible combination of community-level BSDs.
replicate-becs
# use same community combinations as before
bsd_crosscomm_ks = lapply(community_combinations, FUN = ks_bsd,
ln_mass_vals = F)
=======
rr
bsd_crosscomm_ks = lapply(community_combinations, FUN = ks_bsd, ln_mass_vals = F)
>>>>>>> energy-assumptions